#ifndef SJIS_HEADER
#define SJIS_HEADER

// this header needs
#include <stdio.h>
#include "../ARRAY.h"
#include "ASCII.h"
#include "UNICD.h"

// epik SJIS map table
// some important constants are defined here
#include "SHIFT_JIS_U_TB.h"

// Shift_JIS
// I based these functions and tables on the information of these pages.
// https://www.haible.de/bruno/charsets/conversion-tables/Shift_JIS.html
// https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT
// I am assuming the "Shift_JIS" encoding is the one from that SHIFTJIS.TXT file.

// will represent an SJIS character as with
// an umax container (as there are 1-2 byte characters)
typedef umax sjis_int;

// Shift JIS is a character encoding that has japanese characters
// As CP932, for me it is a mess as I don't read japanese.

#define INV_SJIS_INT 0x80
#define INV_SJIS_INT_STR "[INV_SJIS_INT]"
#define INV_ENC_SJIS_STR "[INV_ENC_SJIS]"

// this encoding almost inherits the ASCII table characters

// table definitions
#define SJIS_ASCII_INV1 0x5C
#define SJIS_ASCII_INV2 0x7E
#define SJIS_ASCII_INT_CTRL_CHARS_START  0x00
#define SJIS_ASCII_INT_CTRL_CHARS_END    0x19
#define SJIS_ASCII_INT_PRINT_CHARS_START 0x20
#define SJIS_ASCII_INT_PRINT_CHARS_END   0x7F
#define SJIS_ASCII_INT_COMMA             0x2C
#define SJIS_ASCII_INT_NEWLN             0xA0
#define SJIS_ASCII_INT_WHITESPACE_LENGTH 6
unicd_int * SJIS_ASCII_INT_WHITESPACE = ASCII_INT_WHITESPACE;

#define SJIS_ASCII_INT_NUMBER_BEGIN 0
#define SJIS_ASCII_INT_NUMBER_HEX_UPPER_BEGIN 10
#define SJIS_ASCII_INT_NUMBER_HEX_LOWER_BEGIN 16
#define SJIS_ASCII_INT_NUMBER_PMDX_BEGIN 22
#define SJIS_ASCII_INT_NUMBER_LENGTH 26
unicd_int * SJIS_ASCII_INT_NUMBER = ASCII_INT_NUMBER;

// checking
byte check_sjis_int(sjis_int ch);
byte check_enc_sjis(void * src, umax ssize);
// get/write
sjis_int get_sjis_int(void * src, umax ssize);
void * write_enc_sjis(sjis_int ch, void * dest, umax dsize);
// printing
byte print_sjis_int(sjis_int ch);
byte print_enc_sjis(void * src, umax ssize);

// unicode conversion related

// checking
byte check_sjis_as_unicd(sjis_int ch);
bool check_unicd_as_sjis(unicd_int ch);
// getting
unicd_int get_sjis_as_unicd(sjis_int ch);
sjis_int get_unicd_as_sjis(unicd_int ch);

#include "SHIFT_JIS.c"

#endif // SJIS_HEADER
